package com.vorli;

import java.math.*;

import android.widget.TextView;

public class eggcalc {
	private final double eiconst = 0.0016;
	private double kochminuten; // float
	private double eggtemp; // degree celsius
	private double water;  // degree celsius
	private double eggsize; // milimeter
	private double egginnen; // degree celsius
	private TextView tv;
	
	public eggcalc(TextView tv,int eggtemp, int water, int eggsize, int egginnen) {
		super();
		this.eggtemp = eggtemp;
		this.water = water;
		this.eggsize = eggsize;
		this.egginnen = egginnen;
		this.kochminuten = 0;
		calckochmin();
	}

	public void setEggsize(int eggsize) {
		this.eggsize = eggsize;
	}

	public void setEggtemp(int eggtemp) {
		this.eggtemp = eggtemp;
	}
	
	public void setEgginnen(int egginnen) {
		this.egginnen = egginnen;
	}

	public void calckochmin() {
		this.kochminuten = eiconst * Math.pow(eggsize,2.0) * Math.log((2 * (water-eggtemp)) / (water - egginnen));
	}
	
	public double getKochminuten() {
		return kochminuten;
	}
	
	public double getKochsek() {
		return kochminuten*60;
	}
	
	public void getMinAnzeige() {
		int min;
		int sek;
		String zeitstr;
		min = (int) Math.floor(kochminuten);
		sek = (int) Math.floor(60*(kochminuten - min));
		if(min<10) {
			zeitstr = "0" + min + ":";
		} else {
			zeitstr = min + ":";
		}	
		if(sek<10) {
			zeitstr = zeitstr + "0" + sek;
		} else {
			zeitstr = zeitstr + sek;
		}	
		tv.setText(zeitstr);
	}
	
}


